package com.wwwc.index.servlet;

import java.io.*;
import java.awt.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.ServletRequestWrapper;
import java.net.*;

public class HtmlUtils {

    public static StringBuffer getXmlComments(String title) {
	StringBuffer sbf = new StringBuffer();
	sbf.append("\n<!-- ============================= "+title+" ============================= -->\n");
	return sbf;
    }

    public static StringBuffer getStyleSheet(String title) {
	StringBuffer sbf = new StringBuffer();
	sbf.append("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n");
	sbf.append("<head>\n");
	sbf.append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />\n");
	sbf.append("<meta http-equiv=\"Content-Style-Type\" content=\"text/css\" />\n");
	sbf.append("<title>\""+title+"\"</title>\n");
	sbf.append("</head>\n");
	sbf.append("<link rel=\"shortcut icon\" href=\"/images/favicon.ico\" type=\"image/x-icon\" />\n");
	return sbf;
    }

    public static StringBuffer getStyleSheet(String title, String key_words) {
	StringBuffer sbf = new StringBuffer();
	sbf.append("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n");
	sbf.append("<head>\n");
	sbf.append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />\n");
	sbf.append("<meta http-equiv=\"Content-Style-Type\" content=\"text/css\" />\n");
	if(key_words != null && key_words.length()>0) {
	    sbf.append("<meta name=\"keywords\" content=\""+key_words+"\" />\n");
	}
	sbf.append("<title>\""+title+"\"</title>\n");
	sbf.append("</head>\n");
	sbf.append("<link rel=\"shortcut icon\" href=\"/images/favicon.ico\" type=\"image/x-icon\" />\n");
	return sbf;
    }

    public static StringBuffer getStyleSheet(String title, String key_words, String refresh) {
	StringBuffer sbf = new StringBuffer();
	sbf.append("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n");
	sbf.append("<head>\n");
	sbf.append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />\n");
	sbf.append("<meta http-equiv=\"Content-Style-Type\" content=\"text/css\" />\n");

	if(refresh != null && refresh.length()>0) {
	    sbf.append("<meta http-equiv=\"Refresh\" Content=\""+refresh+"\">");
	}

	if(key_words != null && key_words.length()>0) {
	    sbf.append("<meta name=\"keywords\" content=\""+key_words+"\">\n");
	}

	sbf.append("<title>\""+title+"\"</title>\n");
	sbf.append("</head>\n");
	sbf.append("<link rel=\"shortcut icon\" href=\"/images/favicon.ico\" type=\"image/x-icon\" />\n");
	return sbf;
    }
    
    public static StringBuffer urlReloadScript (String url) {
	StringBuffer sbf = new StringBuffer();
	sbf.append("<SCRIPT>");
	sbf.append("  top.location.replace(\""+url+"\");");
	sbf.append("</SCRIPT>");
	return sbf;
    }
}
